class BaseService {
  constructor(modelInstance) {
    this.modelInstance = modelInstance;
  }

  async getList(query, ctx) {
    return await this.modelInstance.getList(query, ctx);
  }

  async getPage(query, ctx) {
    return await this.modelInstance.getPage(query, ctx);
  }

  async add(data, ctx) {
    return await this.modelInstance.add(data, ctx);
  }

  async update(data, ctx) {
    return await this.modelInstance.update(data.id, data, ctx);
  }

  async remove(id, ctx) {
    return await this.modelInstance.remove(id, ctx);
  }

  async softDelete(id, ctx) {
    return await this.modelInstance.softDelete(id, ctx);
  }

  async removes(ids, ctx) {
    let _ids = ids;
    if (typeof ids === "string") {
      if (!ids.includes(",")) {
        _ids = [ids];
      } else {
        _ids = ids.split(",");
      }
    }
    return await this.modelInstance.removes(ids, ctx);
  }

  async softDeletes(ids, ctx) {
    let _ids = ids;
    if (typeof ids === "string") {
      if (!ids.includes(",")) {
        _ids = [ids];
      } else {
        _ids = ids.split(",");
      }
    }
    return await this.modelInstance.softDeletes(ids, ctx);
  }

  async getById(id, ctx) {
    return await this.modelInstance.getById(id, ctx);
  }

  async getByIds(ids, ctx) {
    let _ids = ids;
    if (typeof ids === "string") {
      if (!ids.includes(",")) {
        _ids = [ids];
      } else {
        _ids = ids.split(",");
      }
    }
    return await this.modelInstance.getByIds(ids, ctx);
  }
}

module.exports = BaseService;
